<template>
    <div>
        <el-form ref="form" :model="form" label-width="80px">
  <el-form-item label="申请人">
    张三
  </el-form-item>
  <el-form-item label="申请车位">
      2区13号
  </el-form-item>
  <div class="block">
    <span class="demonstration">起始时间</span>
    <el-date-picker
      v-model="form.preorderedStartTime"
      type="datetime"
      default-time="12:00:00"
      placeholder="选择日期时间">
    </el-date-picker>
  </div>
  <br>
  <div class="block">
    <span class="demonstration">结束时间</span>
    <el-date-picker
      v-model="form.preorderedEndTime"
      type="datetime"
      placeholder="选择日期时间">
    </el-date-picker>
  </div>
  <br>
  <el-form-item>
    <el-button type="primary" @click="b">提交</el-button>
    <el-button type="primary" @click="onSubmit">取消</el-button>
  </el-form-item>
</el-form>
    </div>
</template>

<script>
export default {
    name:"subscribe",
     data() {
      return {
        form: {
          userId: 2,
          parkingPlaceId: 1,
          preorderedStartTime: new Date(),
          preorderedEndTime: '',
          type: '预约',
        },
      }
    },
    methods: {
    
      b(){
        var moment = require('moment-timezone')
        moment.tz.setDefault("Asia/Shanghai");
        this.form.preorderedStartTime = moment(this.form.preorderedStartTime).format('YYYY-MM-DD HH:mm:ss');
        this.form.preorderedEndTime = moment(this.form.preorderedEndTime).format('YYYY-MM-DD HH:mm:ss');
        console.log(this.form);
        this.$ax.post('http://192.168.70.33:8092/addOrder',this.form).then((res) =>{
          console.log(res);
        }).catch(error =>{
          console.error(error);
        });
        this.$router.push({name:"yesPay"})
      },
      onSubmit(){
        this.$router.push({name:"carport"})
      }
    }
}
</script>